package com.book.demo.Service.ServiceIMP;

import com.book.demo.Mapper.GonggaoMapper;
import com.book.demo.Pojo.Gonggao;
import com.book.demo.Service.GonggaoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class GonggaoServiceIMP implements GonggaoService {

    @Autowired
    private GonggaoMapper gonggaoMapper;

    /**
     * 新增数据
     *
     * @param gonggao 实例对象
     * @return 实例对象
     */
    @Override
    public Map<String, Object> AdminAddGonggao(Gonggao gonggao) {
        Map<String, Object> result = new HashMap<>();
        try {
            // TODO: 新增数据
            if (gonggaoMapper.AdminAddGonggao(gonggao) > 0) {
                result.put("code", 200);
                result.put("msg", "新增成功");
                result.put("result", true);
            } else {
                result.put("code", 200);
                result.put("msg", "新增失败");
                result.put("result", false);
            }
        } catch (Exception e) {
            e.printStackTrace();
            result.put("code", 500);
            result.put("msg", "新增失败,服务器错误");
            result.put("result", false);
        }
        return result;
    }
}
